package com.sharding.demo.interfaces;


import com.sharding.demo.domain.entity.TOrder;
import com.sharding.demo.domain.service.TOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class TOrderController {

    private final TOrderService tOrderService;


    @Autowired
    public TOrderController(TOrderService tOrderService) {
        this.tOrderService = tOrderService;
    }



    @GetMapping("/insertOne")
    public int insertOne(){
        TOrder tOrder = new TOrder();
        tOrder.setOrderId(1L);
        tOrder.setUserId(1L);
        tOrder.setPrice(new BigDecimal(1));
        tOrder.setStatus("1");
        return tOrderService.insert(tOrder);
    }

    @GetMapping("/tOrder")
    public TOrder getTOrder(){
        Long orderId = 1L;
        return tOrderService.getTOrder(orderId);
    }

}
